package emp.entity;

import java.util.List;

public class PageInfo<T> {
    private int currentPage;   // 当前页码
    private int pageSize;      // 每页记录数
    private int totalRecords;  // 总记录数
    private int totalPages;    // 总页数
    private List<T> content;   // 当前页的数据

    public PageInfo(int currentPage, int pageSize, int totalRecords, List<T> content) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalRecords = totalRecords;
        this.content = content;
        this.totalPages = (int) Math.ceil((double) totalRecords / pageSize); // 计算总页数
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalRecords() {
        return totalRecords;
    }

    public void setTotalRecords(int totalRecords) {
        this.totalRecords = totalRecords;
    }

    public int getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public List<T> getContent() {
        return content;
    }

    public void setContent(List<T> content) {
        this.content = content;
    }
}
